#!/usr/bin/env ruby -wKU

require 'net/http'
require 'CGI'

http = Net::HTTP.new('myanimelist.net', 80)
headers = {
  'Referer' => 'http://myanimelist.net',
  'Content-Type' => 'application/x-www-form-urlencoded'
}
resp = http.post('/login.php', 'username='+CGI::escape('user')+'&password='+CGI::escape('password')+'&cookie=true',headers)
cookieY = resp.response['set-cookie'].split(', ')[0].split('; ')[0]
cookieZ = resp.response['set-cookie'].split(', ')[2].split('; ')[0]
cookie = cookieY+"; "+cookieZ

headers = {
  'Cookie' => cookie,
  'Content-Type' => 'application/x-www-form-urlencoded',
}

resp = http.post('/includes/change_ep.php', 'series_id='+CGI::escape('7851642')+'&ep_val='+CGI::escape('26'), headers)